package com.test.animation;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

import com.test.R;

public class ViewAnimationActivity extends Activity {
	
	private Button button;
	private ListView listView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.listview);
		findView();
		setupListView();
		
	}
	
	private void findView(){
		button = (Button) findViewById(R.id.button);
		listView = (ListView) findViewById(R.id.listview);
		button.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				animate();
			}
		});
	}
	
	private void setupListView(){
		String[] items = new String[]{"item1","tem2","tem3"	,"tem4"	,"tem5"	,"tem6"	,"tem7"	,"tem8"	,"tem9"};
		listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items));
	}

	protected void animate() {
		listView.startAnimation(new ViewAnimation());
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		this.finish();
	}
}